package com.lam.mall.listener;

import com.lam.common.components.easyexcel.imp.listener.BaseListener;
import com.lam.common.components.easyexcel.imp.model.ImportEntry;
import com.lam.common.components.easyexcel.imp.model.ImportWrapper;
import com.lam.common.context.TokenUtils;
import com.lam.mall.entity.HotSearch;
import com.lam.mall.entity.imp.HotSearchImp;
import com.lam.mall.service.HotSearchService;

/**
 * 热搜管理导入读取类 
 * 此类不能单例，要每次读取excel都要new 
 * @author admin
 *
 */
public class UploadHotSearchListener extends BaseListener<HotSearchImp, HotSearch> {
	
	private HotSearchService hotSearchService;

	public UploadHotSearchListener(HotSearchService hotSearchService) {
		super(HotSearchImp.class, HotSearch.class);
		this.hotSearchService = hotSearchService;
	}

	//重新该方法可自定义校验数据
	@Override
	protected String checkData(ImportEntry<HotSearchImp, HotSearch> entry) {
		entry.getData().setShopId(TokenUtils.getLoginUserShopId());
		//自定义校验数据逻辑
		return super.checkData(entry);
	}

	@Override
	protected void saveSuccessData(ImportWrapper<HotSearchImp, HotSearch> wrapper) {
		
		hotSearchService.importData(wrapper);
	}


}
